package com.cyz.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.cyz.service.ProductService;
import com.cyz.service.impl.ProductServiceImpl;

@Controller
@RequestMapping("/Product")
public class Product {
	@RequestMapping ("/product")
	public ModelAndView  productDetail( HttpServletRequest request,HttpServletResponse response)
	{
		ModelAndView mv=new ModelAndView();
		mv.setViewName("product");
		String productName = request.getParameter("productName");
		
		ProductService productService = new ProductServiceImpl();
		com.cyz.pojo.Product product = productService.getProductByProductName(productName);
		//productService.getProductById();
		mv.addObject("product",product);
		mv.addObject("productName",productName);
		mv.addObject("prePage",request.getSession().getAttribute("nowPage"));
		request.getSession().setAttribute("nowPage","/Shopping/Product/product?productName="+productName);
		//mv.setViewName("product");
		return  mv;
	}
}
